package org.jsola.hr.helper;

import org.jsola.common.ClassKit;
import org.jsola.common.SafeKit;
import org.jsola.hr.dto.TransferAccountsZfbDetailAddDTO;
import org.jsola.hr.dto.TransferAccountsZfbDetailUpdateDTO;
import org.jsola.hr.entity.TransferAccountsZfbDetailDO;
import org.jsola.hr.query.TransferAccountsZfbDetailQuery;
import org.jsola.hr.service.ITransferAccountsZfbDetailService;
import org.jsola.hr.vo.TransferAccountsZfbDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账明细(支付宝)
 *
 * @author zhr
 */
@Component
public class TransferAccountsZfbDetailTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsZfbDetailService transferAccountsZfbDetailService;

    /**
     * 生成add测试数据
     * @return TransferAccountsZfbDetailAddDTO
     */
    public TransferAccountsZfbDetailAddDTO getTransferAccountsZfbDetailAddDTO(){
        TransferAccountsZfbDetailAddDTO transferAccountsZfbDetailAddDTO = new TransferAccountsZfbDetailAddDTO();
        transferAccountsZfbDetailAddDTO.setName(getRandomValue("varchar",256));
        transferAccountsZfbDetailAddDTO.setPayeeAccount(getRandomValue("varchar",100));
        transferAccountsZfbDetailAddDTO.setPayeeType(getRandomValue("varchar",32));
        transferAccountsZfbDetailAddDTO.setPayeeName(getRandomValue("varchar",140));
        transferAccountsZfbDetailAddDTO.setMoney(SafeKit.getBigDecimal(getRandomValue("decimal",11)));
        transferAccountsZfbDetailAddDTO.setOrderTitle(getRandomValue("varchar",64));
        transferAccountsZfbDetailAddDTO.setRemark(getRandomValue("varchar",256));
        transferAccountsZfbDetailAddDTO.setZfbBatchId(getRandomValue("varchar",32));
        transferAccountsZfbDetailAddDTO.setDetailId(getRandomValue("varchar",32));
        transferAccountsZfbDetailAddDTO.setStatus(getRandomValue("varchar",16));
        transferAccountsZfbDetailAddDTO.setAlipayOrderNo(getRandomValue("varchar",64));
        transferAccountsZfbDetailAddDTO.setErrorCode(getRandomValue("varchar",100));
        transferAccountsZfbDetailAddDTO.setErrorMsg(getRandomValue("varchar",200));
        transferAccountsZfbDetailAddDTO.setZfbGmtCreate(getRandomValue("varchar",64));
        transferAccountsZfbDetailAddDTO.setZfbGmtFinish(getRandomValue("varchar",64));
        transferAccountsZfbDetailAddDTO.setPayTime((Date)ClassKit.getObjectValue(getRandomValue("datetime",0),"java.util.Date"));
        return transferAccountsZfbDetailAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsZfbDetailUpdateDTO
     */
    public TransferAccountsZfbDetailUpdateDTO getTransferAccountsZfbDetailUpdateDTO(TransferAccountsZfbDetailVO transferAccountsZfbDetailVO){
        return transferAccountsZfbDetailService.selectDOById(transferAccountsZfbDetailVO.getId(), SITE_ID).to(TransferAccountsZfbDetailUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsZfbDetailQuery
     */
    public TransferAccountsZfbDetailQuery getTransferAccountsZfbDetailQuery() {
        TransferAccountsZfbDetailQuery transferAccountsZfbDetailQuery = new TransferAccountsZfbDetailQuery();
        List<TransferAccountsZfbDetailDO> transferAccountsZfbDetailDOList = transferAccountsZfbDetailService.list(new TransferAccountsZfbDetailDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsZfbDetailDOList)) {
            TransferAccountsZfbDetailDO transferAccountsZfbDetailDO = transferAccountsZfbDetailDOList.get(0);
            transferAccountsZfbDetailQuery = transferAccountsZfbDetailDO.to(TransferAccountsZfbDetailQuery.class);
        }
        return transferAccountsZfbDetailQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsZfbDetailVO
     */
    public TransferAccountsZfbDetailVO saveTransferAccountsZfbDetailExample(){
        TransferAccountsZfbDetailAddDTO addDTO = this.getTransferAccountsZfbDetailAddDTO();
        TransferAccountsZfbDetailVO transferAccountsZfbDetailVO = transferAccountsZfbDetailService.save(addDTO,buildTokenUser());
        return transferAccountsZfbDetailVO;
    }


}

